package com.window;

import com.event.*;

import javax.swing.*;
import java.awt.*;


public class select extends JFrame {
    FlowLayout flowlayout;
    JLabel title, aaa, bbb, ccc, ddd;
    public static JButton a, b, c, d;
    public static JTextField aa, bb, cc, dd;


    final int WIDTH = 320;//框架宽度
    final int HEIGHT = 270;//框架高度

    public select() {
        init();
        setVisible(true);//设置窗口可视化
        setResizable(false);//设置窗口大小不可变
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);//设置默认关闭方式
        validate();//让组件生效
        setName();
        allevent();
    }

    void init() {
        flowlayout = new FlowLayout(FlowLayout.CENTER);//布局居中
        this.setLayout(flowlayout);
        //设置窗口大小与位置
        Toolkit kit = Toolkit.getDefaultToolkit();
        Dimension screenSize = kit.getScreenSize();
        int width = screenSize.width;
        int height = screenSize.height;
        int x = (width - WIDTH) / 2;
        int y = (height - HEIGHT) / 2;
        this.setBounds(x, y, WIDTH, HEIGHT);//设置窗口位置与大小

        Font f = new Font("宋体", Font.BOLD, 42);//初始化字体
        Font f1 = new Font("宋体", Font.BOLD, 18);//初始化字体

        title = new JLabel("选择一个方式");
        title.setFont(f);


        a = new JButton("学号查找");
        a.setFont(f1);
        b = new JButton("性别查找");
        b.setFont(f1);
        c = new JButton("班级查找");
        c.setFont(f1);
        d = new JButton("年龄查找");
        d.setFont(f1);
        aa = new JTextField(8);
        aa.setFont(f1);
        bb = new JTextField(8);
        bb.setFont(f1);
        cc = new JTextField(8);
        cc.setFont(f1);
        dd = new JTextField(8);
        dd.setFont(f1);
        aaa = new JLabel("输入学号");
        bbb = new JLabel("输入性别");
        ccc = new JLabel("输入班级");
        ddd = new JLabel("输入年龄");
        aaa.setFont(f1);
        bbb.setFont(f1);
        ccc.setFont(f1);
        ddd.setFont(f1);


        this.add(title);
        this.add(aaa);
        this.add(aa);
        this.add(a);
        this.add(bbb);
        this.add(bb);
        this.add(b);
        this.add(ccc);
        this.add(cc);
        this.add(c);
        this.add(ddd);
        this.add(dd);
        this.add(d);
    }

    //定义监听
    void allevent() {
        SelectEvent lis = new SelectEvent();

        a.addActionListener(lis);
        b.addActionListener(lis);
        c.addActionListener(lis);
        d.addActionListener(lis);

    }

    //定义名字
    void setName() {
        a.setName("a");
        b.setName("b");
        c.setName("c");
        d.setName("d");
    }


}
